package cn.hdu.liang.ch4;

public class InheritableThreadLocalDemo {
    private static final InheritableThreadLocal<Integer> intVal = new InheritableThreadLocal<>();

    public static void main(String[] args) {
        Runnable rp = () -> {
            intVal.set(10);
            Runnable rc = () -> {
                Thread thd = Thread.currentThread();
                String name = thd.getName();
                System.out.printf("%s %d%n", name, intVal.get());
            };

            Thread thdChild = new Thread(rc, "Child");
            thdChild.start();
        };
        new Thread(rp).start();
    }
}
